{% extends 'base.html' %}
{% load static %}
{% block title %}工资条管理 - 发送结果{% endblock %}
{% block content %}
<div id="dg" style="z-index: 9999; position: fixed ! important; right: 3%; top: 80%;">
    <button id="submit" style="border: none;height: 40px;width: 70px;border-radius: 5px; background-color: #00c054;text-align: center;" title="点击确认，开始发送">
    <i class="fa fa-paper-plane" style="font-size: 20px;color: whitesmoke;padding-top: 13%" aria-hidden="true"></i>
    </button>

    <div class="row" style="height: 10px;"></div>
<a href="/">
    <div style="height: 40px;width: 70px;border-radius: 5px; background-color: red;text-align: center;" title="有错，取消发送">
    <i class="fa fa-times" style="font-size: 20px;color: whitesmoke;padding-top: 18%" aria-hidden="true"></i>
    </div>
</a>
</div>
<section class="content">
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body table-responsive table-bordered ">
                    {% for html in data %}
                        {{ html|safe }}
                        <div class="row" style="height: 20px;"></div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
</div>
</section>
{% block custom_js %}
<script>
//post提交的csrf认证
$.ajaxSetup({
    data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
$(document).ready(function () {
    $("#submit").click(function () {
        $.ajax({
            url: '{% url 'payroll:send' %}',
            type: 'POST',
            async: true,
            data: {
                'salary_file': '{{ salary_file|safe }}',
                'send_way': '{{ send_way }}',
                'subject': '{{ subject }}',
                'send_year': '{{ send_year }}',
                'send_month': '{{ send_month }}',
                'paymonth': '{{ paymonth }}',
            },
            //请求成功后执行提醒
            success: function (data) {
                if (data.status === 0){   //如果添加失败，则停留在此
                    layui.use('layer',function () {
                        var layer = layui.layer;
                        layer.alert(data.info, {
                            icon: 2,
                            skin: 'layer-ext-moon',
                        });
                    })
                }else {
                    layui.use('layer',function () {
                        var layer =layui.layer;
                        layer.alert(data.info, {
                            icon: 1,
                            skin: 'layer-ext-moon',
                            yes: function(){
                                location.href = '{% url 'payroll:his' %}';
                            }
                        });
                    })
                }
            }
    });
});
})
</script>
{% endblock %}
{% endblock %}


